﻿using Autofac;
using Autofac.Integration.Mvc;
using SqlSugar;
using System.Web.Mvc;
using wnet.admin.Controllers;
using wnet.admin.Controllers.pcapi;

namespace wnet.admin.dbhelper
{
    public class AutofacConfig
    {
        //public static void Register()
        //{
        //    var builder = new ContainerBuilder();

        //    // 配置SqlSugarClient
        //    var db = new SqlSugarClient(new ConnectionConfig()
        //    {
        //        ConnectionString = Config.ConnectionString,
        //        DbType = DbType.SqlServer,
        //        IsAutoCloseConnection = true,
        //        InitKeyType = InitKeyType.Attribute
        //    });

        //    // 注册SqlSugarClient实例
        //    builder.RegisterInstance(db).As<ISqlSugarClient>().SingleInstance();

        //    //builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IBaseRepository<>)).InstancePerDependency(); //注册仓储
        //    //builder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).InstancePerDependency();

        //    // 注册控制器
        //    //builder.RegisterControllers(typeof(systemController).Assembly);
        //    // 构建容器
        //    var container = builder.Build();

        //    // 使用Autofac的DependencyResolver设置MVC控制器的依赖注入
        //    DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
           
        //}
    }
}